@tool
class_name Cost_Expression
extends Cost_Single

@export var expression_properties:Dictionary
var check_expression:String = ""
var do_expression:String = ""

func check_cost(entity:Entity) -> bool:
	return CostUtil.check_cost(entity,self)
func do_cost(entity:Entity,args:Dictionary = {}) -> bool:
	return CostUtil.do_cost(entity,self,args)

func _get_property_list() -> Array[Dictionary]:
	var properties:Array[Dictionary] = []
	properties.append({
		"name": "check_expression",
		"type": TYPE_STRING,
		"usage": PROPERTY_USAGE_DEFAULT,
		"hint": PROPERTY_HINT_EXPRESSION
	})
	properties.append({
		"name": "do_expression",
		"type": TYPE_STRING,
		"usage": PROPERTY_USAGE_DEFAULT,
		"hint": PROPERTY_HINT_EXPRESSION
	})
	return properties

func _init() -> void:
	cost_type = "Expression"
	expression_properties["cost_value"] = cost_value
	changed.connect(func():
		cost_type = "Expression"
		expression_properties["cost_value"] = cost_value
	)
